package com.gexin.model.plug;

import com.gexin.common.utils.SQLUtils;
import com.gexin.common.utils.StringUtil;
import com.gexin.model.plug.base.BaseMessagePush;
import com.jfinal.plugin.activerecord.Page;

/**
 * 业务名称:  t_message_push(消息推送表) 
 */
@SuppressWarnings("serial")
public class MessagePush extends BaseMessagePush<MessagePush> {
	public static final MessagePush dao = new MessagePush();
	
	public Page<MessagePush> paginate(int pageNumber, int pageSize,MessagePush m) {
		SQLUtils sql  = new SQLUtils("from t_message_push where 1=1 ");
		if(m!=null){
			if(StringUtil.isNotBlank(m.getTitle())){
				sql.whereLike("title", m.getTitle());
			}
			if(StringUtil.isNotBlank(m.getMsgType())){
				sql.whereEquals("msg_type", m.getMsgType());
			}
			
			/*
            if(StringUtil.isNotBlank(user.getStr("startdate")) && StringUtil.isNotBlank(user.getStr("enddate"))){
				sql.append(String.format(" and createtime BETWEEN '%s' and '%s'", user.getStr("startdate"),user.getStr("enddate")));
			}
			if(StringUtil.isNotBlank(user.getChannelName())){
				sql.whereLike("channel_name", user.getChannelName());
			}*/
		}
		sql.append(" order by createtime desc ");
		return paginate(pageNumber, pageSize, "select * ", sql.toString());
	}
	
	
}
